//
//  RecImageWebViewController.m
//  TravelEveryDay
//
//  Created by dlios on 15-10-22.
//  Copyright (c) 2015年 com.lanou3g. All rights reserved.
//

#import "RecImageWebViewController.h"
#import "RecStoryDetailsViewController.h"
#import "RecUserViewController.h"
@interface RecImageWebViewController ()<UIWebViewDelegate>

@end

@implementation RecImageWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIWebView *web = [[UIWebView alloc] initWithFrame:self.view.frame];
    [web setScalesPageToFit:YES];
    web.delegate = self;
    [self.view addSubview:web];
    
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.url]];
    [web loadRequest:request];
    
}
//截取web跳转的字符串
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
   
    if ([request.URL.absoluteString containsString:@"app:jump:spot:"]) {
        RecStoryDetailsViewController *vc = [[RecStoryDetailsViewController alloc] init];
        vc.myId = [NSNumber numberWithInteger:[request.URL.absoluteString substringFromIndex:14].integerValue];
        [self.navigationController pushViewController:vc animated:YES];
    }
    if ([request.URL.absoluteString containsString:@"app:jump:user:"]) {
        RecUserViewController *user = [[RecUserViewController alloc] init];
        user.userId = [NSNumber numberWithInteger:[request.URL.absoluteString substringFromIndex:14].integerValue];
        [self.navigationController pushViewController:user animated:YES];
    }

    return YES;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
